/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.evaluation;

import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * 测评结论
 * @author zpy
 * @version 1.0.0
 */
public enum EvaluationConclusion {
    /**未判定**/
    DEFAULT(0,"未判定"),
    /**符合**/
    MATCH(1,"符合"),
    /**部分符合**/
    PARTIALLY_MATCH(2,"部分符合"),
    /**不符合**/
    NOT_MATCH(3,"不符合"),
    /**不适用**/
    NOT_APPLICABLE(4,"不适用");

    private final int conclusion;
    private final String name;

    EvaluationConclusion(int conclusion, String name) {
        this.conclusion = conclusion;
        this.name = name;
    }

    public static EvaluationConclusion fromConclusion(Integer conclusion){
        EvaluationConclusion data = DEFAULT;
        for(EvaluationConclusion tt :EvaluationConclusion.values()){
            if(tt.conclusion == conclusion){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static EvaluationConclusion fromName(String name){
        EvaluationConclusion data = DEFAULT;
        for(EvaluationConclusion tt :EvaluationConclusion.values()){
            if(StringUtils.equals(tt.getName(),name)){
                data = tt;
                break;
            }
        }
        return data;
    }

    public static List<EvaluationConclusion> findAllByManage(){
        return List.of(EvaluationConclusion.MATCH,
                EvaluationConclusion.PARTIALLY_MATCH,
                EvaluationConclusion.NOT_MATCH,
                EvaluationConclusion.NOT_APPLICABLE);
    }

    public int getConclusion(){
        return this.conclusion;
    }

    public String getName(){
        return this.name;
    }
}